package com.class04.config;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassDescription:
 * 项目的配置类，controller、handlermapping handlerAdapater
 * 加入ioc容器
 * @JdkVersion: 17
 * @Author: yxy
 * @Created: 2023/12/4 8:07
 */
@EnableWebMvc
@ComponentScan("com.class04.controller")
@Configuration
public class MvcConfig implements WebMvcConfigurer {
//    handlerMapping handlerAdapter
//    中配置视图解析器  指定前后缀
    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
//        registry可以快速添加前后缀
        registry.jsp("/WEB-INF/views/",".jsp");
//        handler -> index
    }
//   开启静态资源查找

    @Override
    public void configureDefaultServletHandling
            (DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }
}
